package com.zzz.robot201.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.zzz.robot201.R;

public class LoadingDialog extends Dialog {

    private String msg = "加载中...";
    private boolean isBackDismiss;

    public LoadingDialog(@NonNull Context context) {
        super(context, R.style.BaseDialog);
        initView(context);
    }

    public LoadingDialog(@NonNull Context context, String msg) {
        super(context, R.style.BaseDialog);
        this.msg = msg;
        initView(context);

    }

    private void initView(Context context) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);
        setCanceledOnTouchOutside(false);

    }

    public LoadingDialog notCancel() {
        isBackDismiss = true;
        return this;
    }

    public void setNotCancel() {
        isBackDismiss = true;
    }

    @Override
    public void onBackPressed() {
        if (!isBackDismiss) super.onBackPressed();
    }
}
